﻿using NuMvvm.Commands;
using NuMvvm.Services;
using NuMvvm.Testing.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Todo.Tests.Mocks;
using Todo.ViewModels;
using NUnit.Framework;
using Todo.Views;

namespace Todo.Tests
{
    public class MainViewModelTest
    {
        [TestCase]
        public async Task Initialize()
        {
            Services.IDataService dataService = new MockDataService();
            IDialogService dialogService = new MockDialogService();
            INavigationService navigationService = new MockNavigationService();

            var mainViewModel = new MainViewModel(dataService, dialogService, navigationService);
            await mainViewModel.Initialize();

            Assert.IsTrue(mainViewModel.Items.Count == 3);
        }

        [TestCase]
        public async Task ShowItem()
        {
            Services.IDataService dataService = new MockDataService();
            IDialogService dialogService = new MockDialogService();
            INavigationService navigationService = new MockNavigationService();

            var mainViewModel = new MainViewModel(dataService, dialogService, navigationService);
            mainViewModel.ShowItemCommand.Execute(2);

            var view = navigationService.CurrentView as MockView;

            Assert.IsTrue(view.View == ViewKeys.Item);
            Assert.IsTrue((int)view.Argument == 2);
        }
    }
}
